package com.heima.wemedia.controller;

import com.alibaba.fastjson.JSON;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.IsPassDto;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.wemedia.mapper.WmNewsMapper;
import com.heima.wemedia.service.WmNewsClientService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
public class WemediaClientController {

    private final WmNewsClientService wmNewsClientService;

    @PostMapping("/findList")
    public PageResponseResult findList(@RequestBody String str){
        NewsAuthDto dto = JSON.parseObject(str, NewsAuthDto.class);
        log.info("人工审核端查询文章列表：{}",dto);
        return wmNewsClientService.findList(dto);
    }

    @PostMapping("/findOne")
    public ResponseResult findOne(@RequestBody  Integer id){
        log.info("查询详情：{}",id);
        return wmNewsClientService.findOne(id);
    }

    @PostMapping("/isPass")
    public ResponseResult isPass(@RequestBody  String str){
        IsPassDto dto = JSON.parseObject(str, IsPassDto.class);
        log.info("是否通过：{}",dto);
        return wmNewsClientService.isPass(dto);
    }



}
